package com.project.demo2;

import java.util.ArrayList;
import java.util.List;

public class Astar {
    public static void main(String[] args) {
        int[][] map = {
                {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
                {-1,  0,  0,  0,  0,  0,  0,  0,  0, -1},
                {-1,  0,  0,  0,  0, -1,  0,  0,  0, -1},
                {-1,  0,  0,  0, -1,  0,  0,  0,  0, -1},
                {-1,  0,  1,  0, -1,  0,  0,  2,  0, -1},
                {-1,  0,  0,  0,  0, -1,  0,  0,  0, -1},
                {-1,  0,  0,  0, -1,  0,  0,  0,  0, -1},
                {-1,  0,  0,  0,  0, -1,  0,  0,  0, -1},
                {-1,  0,  0,  0,  0,  0,  0,  0,  0, -1},
                {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}
        };
        Node start = new Node(4, 2);
        start.Father = null;
        Node end = new Node(4, 7);
        Solution solution = new Solution();
        Node res_node = solution.astarSearch(start, end);

        List<Node> list = new ArrayList<>();
        //渲染迷宫
        while (res_node != null) {
            list.add(res_node);
            map[res_node.x][res_node.y] = 11;
            res_node = res_node.Father;//迭代操作
        }
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                System.out.printf("%3d", map[i][j]);
            }
            System.out.println();
        }

        for (Node node : list) {
            System.out.println("x:" + node.x + " y:" + node.y);
        }
    }
}
//结点的属性



